<?php
/**
 * Created by PhpStorm.
 * User: 农夫
 * Date: 2017/9/11
 * Time: 10:19
 */
namespace app\model;

use think\Model;
use think\Db;

class Systems extends Model
{
    static $tablue_nmae = 'systems';

    /**
     * 查询一条数据
     * @return array|false|\PDOStatement|string|Model
     */
    static public function findService()
    {
        $return = Db::name(self::$tablue_nmae)->find();
        return $return;
    }

    /**
     * 添加数据
     * @param array $data
     * @return $this
     */
    static public function addService($data = array())
    {
        $return = Db::name(self::$tablue_nmae)->insertGetId($data);
        return $return;
    }

    /**
     * 更新数据或添加数据
     * @param array $data
     * @return $this
     */
    static public function updateServer($data = array())
    {
        $findService = self::findService();
        if ($findService) {
            $where = ['id' => $findService['id']];
            $return = Db::name(self::$tablue_nmae)->where($where)->update($data);
        } else {
            $return = self::addService($data);
        }
        return $return;
    }
}